import requests
import re

url = 'https://liveapi.huya.com/moment/getMomentContent?videoId=893496247&uid=&_=1691139564852'
headers = {
    'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36'
}
response = requests.get(url=url,headers=headers)
title = response.json()['data']['moment']['title']
video_url = response.json()['data']['moment']['videoInfo']['definitions'][0]['url']
#保存数据
video_content = requests.get(url=video_url,headers=headers).content
with open('video\\'+ title +'.mp4',mode='wb') as f:
    f.write(video_content)
print(title,video_url)